package com.dgut.service.background.service;

import com.dgut.service.background.dao.EnterDao;
import com.dgut.service.background.dao.OutsDao;
import com.dgut.service.background.entity.Enter;
import com.dgut.service.background.entity.Outs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HealthService {
    @Autowired
    private OutsDao outsDao;

    @Autowired
    private EnterDao enterDao;

    public int getHealthData(String health){
        List<Outs> outs = outsDao.findAllByHealth(health);
        List<Enter> enters = enterDao.findAllByHealth(health);
        int count = outs.size()+enters.size();
        return count;
    }

    public int findLessThan(double temp){
        List<Outs> outs = outsDao.findAllByTempLessThan(temp);
        List<Enter> enters = enterDao.findAllByTempLessThan(temp);
        int count = outs.size()+enters.size();
        return count;
    }

    public int findGreaterThan(double temp){
        List<Outs> outs = outsDao.findAllByTempGreaterThan(temp);
        List<Enter> enters = enterDao.findAllByTempGreaterThan(temp);
        int count = outs.size()+enters.size();
        return count;
    }

    public int findBetween(double temp1, double temp2){
        List<Outs> outs = outsDao.findAllByTempBetween(temp1, temp2);
        List<Enter> enters = enterDao.findAllByTempBetween(temp1, temp2);
        int count = outs.size()+enters.size();
        return count;
    }
}
